#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>

#define NOISY_TEST 1

//most of the structure and random functions were borrowed from betterTestDrawCard


int checkwhoseTurn(struct gameState *post, int p) {
  int r;
  int errornum = 0;
  r = whoseTurn(post); //call the real function and pass the state

  if (r != p) { //if the real function doesn't match the test
  	  errornum++; //alert an error
    }


  return 0;

}

int main() {
	int n;
	int p;
	int i;

	struct gameState G;

	printf ("Testing whoseTurn():\n");

	//exact copy from betterTestDrawCard.c
	SelectStream(2);
	PutSeed(3);

	for (n = 0; n < 2000; n++) {
	    for (i = 0; i < sizeof(struct gameState); i++) {
	      ((char*)&G)[i] = floor(Random() * 256);
	    }

	// end of exact copy
	    p = floor(Random() * MAX_PLAYERS); //make number of players random
	    G.whoseTurn = p;
	    checkwhoseTurn(&G, p);
	}


	 printf ("ALL TESTS OK\n");

	return 0;
}
